import network, time

def connect():
    wlan = network.WLAN(network.STA_IF)
    wlan.active(True)
    if not wlan.isconnected():
        print('esp32p4 is connecting to network', end="")
        wlan.connect('SSID', 'PWD') 
        while not wlan.isconnected():
            print(".", end="")
            time.sleep(1)
    print('\nNetwork information: ', wlan.ifconfig())  

connect()